import { createStore } from 'vuex'
import getters from './getters';

// 自动化引入vuex模块
const modulesFiles = require.context('./modules', false, /\.ts$/)
const modules = modulesFiles.keys().reduce((modules, modulePath) => {
  const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1') // 规范驼峰命名
  const value = modulesFiles(modulePath)
  modules[moduleName] = value.default
  return modules
}, {} as {[key: string]: any})


export default createStore({
  state: {
  },
  mutations: {
  },
  actions: {
  },
  getters,
  modules,
})